package com.pt5.pthouduan.mapper;

import com.pt5.pthouduan.entity.PeerInfo;
import com.pt5.pthouduan.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ljx
 * @since 2025-04-14
 */
@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 根据 passkey 检查用户是否存在
     * @param passkey 用户的 passkey
     * @return 如果存在返回 true，否则返回 false
     */
    boolean existsByPasskey(String passkey);
    void incrementUserTraffic( @Param("info_hash") String infoHash,@Param("passkey") String passkey, @Param("user_upload") long uploaded, @Param("user_download") long downloaded);

    String getUsernameByPasskey(String passkey);

    List<PeerInfo> findSeedersByInfoHash(@Param("infoHash") String infoHash);
}
